# -*- coding: utf8 -*-

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest


def getToken():
    # 创建AcsClient实例
    client = AcsClient(
        "LTAI5tEAdSTMTFp1c1YRj7wi",
        "QUFFzbF0T3kgiFqE4khrx65nscLMPW",
        "cn-shanghai"
    )

    # 创建request，并设置参数。
    request = CommonRequest()
    request.set_method('POST')
    request.set_domain('nls-meta.cn-shanghai.aliyuncs.com')
    request.set_version('2019-02-28')
    request.set_action_name('CreateToken')
    response = client.do_action_with_exception(request)
    token = eval(response)['Token']['Id']

    return token
